import sys
from PyQt5.QtWidgets import QSlider, QApplication, QVBoxLayout, QHBoxLayout, QWidget, QLabel
from PyQt5.QtCore import Qt

class TickPositionDemo(QWidget):
    def __init__(self):
        super().__init__()
        self.setup_ui()
    
    def setup_ui(self):
        layout = QVBoxLayout()
        
        # 无刻度
        self.no_ticks = QSlider(Qt.Horizontal)
        self.no_ticks.setRange(0, 100)
        self.no_ticks.setTickPosition(QSlider.NoTicks)
        
        # 两侧刻度
        self.both_ticks = QSlider(Qt.Horizontal)
        self.both_ticks.setRange(0, 100)
        self.both_ticks.setTickPosition(QSlider.TicksBothSides)
        self.both_ticks.setTickInterval(20)
        
        # 上方刻度（水平滑块）/左侧刻度（垂直滑块）
        self.above_ticks = QSlider(Qt.Horizontal)
        self.above_ticks.setRange(0, 100)
        self.above_ticks.setTickPosition(QSlider.TicksAbove)
        self.above_ticks.setTickInterval(25)
        
        # 下方刻度（水平滑块）/右侧刻度（垂直滑块）
        self.below_ticks = QSlider(Qt.Horizontal)
        self.below_ticks.setRange(0, 100)
        self.below_ticks.setTickPosition(QSlider.TicksBelow)
        self.below_ticks.setTickInterval(10)
        
        layout.addWidget(QLabel("无刻度:"))
        layout.addWidget(self.no_ticks)
        layout.addWidget(QLabel("两侧刻度:"))
        layout.addWidget(self.both_ticks)
        layout.addWidget(QLabel("上方刻度:"))
        layout.addWidget(self.above_ticks)
        layout.addWidget(QLabel("下方刻度:"))
        layout.addWidget(self.below_ticks)
        
        self.setLayout(layout)



if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = TickPositionDemo()
    window.show()
    sys.exit(app.exec_())